import re

d1 = dict(a=1,b='aaa')

inputstr1 = 'hello 123 world 345'
ret = re.sub(r'\d+','333',inputstr1)

inputStr = "hello crifan, nihao crifan"
replacedStr = re.sub(r"crifan", "crifanli", inputStr)

s = '2017-01-22'
s = re.sub('(\d{4})-(\d{2})-(\d{2})', r'\2-\3-\1', s)
print(s) # 01-22-2017

def replace_digit(m):
    ss = u'〇一二三四五六七八九'
    index = int(m.group())
    return ss[index]

s = u'1990年3月27日'
result = re.sub(u'\d', replace_digit, s, count=4)
print(result) # 一九九〇年3月27日